package com.zbkj.admin.controller.platform.monitor;

import com.github.pagehelper.PageInfo;
import com.zbkj.common.annotation.LogControllerAnnotation;
import com.zbkj.common.enums.MethodType;
import com.zbkj.common.model.monitor.ZfbMonitorTrafficSetMeal;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.monitor.ZfbMonitorTrafficSetMealReq;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.monitor.IZfbMonitorTrafficSetMealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ZfbMonitorTrafficSetMealController
 * @Description: 监控设备流量套餐
 * @Author: fanbing
 * @Date: 2024/11/2 10:18
 * @Version: V1.0
 **/

@Slf4j
@RestController
@RequestMapping("api/admin/platform/zfbMonitorTrafficSetMeal")
@Api(tags = "平台端-监控设备流量套餐") //配合swagger使用
public class ZfbMonitorTrafficSetMealController {

    @Autowired
    private IZfbMonitorTrafficSetMealService zfbMonitorTrafficSetMealService;

    @LogControllerAnnotation(intoDB = true, methodType = MethodType.ADD, description = "平台端-新增监控设备流量套餐")
    @ApiOperation(value = "新增-监控设备流量套餐")
    @RequestMapping(value = "/addTrafficSetMeal", method = RequestMethod.POST)
    public CommonResult addTrafficSetMeal(@Validated @RequestBody ZfbMonitorTrafficSetMealReq request) {
        return CommonResult.success(zfbMonitorTrafficSetMealService.add(request));
    }

    @ApiOperation(value = "修改-监控设备流量套餐")
    @LogControllerAnnotation(intoDB = true, methodType = MethodType.UPDATE, description = "修改-监控设备流量套餐")
    @RequestMapping(value = "/editTrafficSetMeal", method = RequestMethod.POST)
    public CommonResult editTrafficSetMeal(@Validated @RequestBody ZfbMonitorTrafficSetMealReq request) {
        return CommonResult.success(zfbMonitorTrafficSetMealService.updateById(request));
    }


    @ApiOperation(value = "列表-监控设备流量套餐")
    @RequestMapping(value = "/trafficSetMealPage", method = RequestMethod.POST)
    public CommonResult<PageInfo<ZfbMonitorTrafficSetMeal>> getPage(@Validated @RequestBody PageParamRequest pageParamRequest) {
        PageInfo<ZfbMonitorTrafficSetMeal> page = zfbMonitorTrafficSetMealService.getPage(pageParamRequest);
        return CommonResult.success(page);
    }

    @ApiOperation(value = "详情-监控设备流量套餐")
    @RequestMapping(value = "/trafficSetMealDetail", method = RequestMethod.GET)
    public CommonResult<ZfbMonitorTrafficSetMeal> trafficSetMealDetail(@RequestParam("id") Integer id) {
        return CommonResult.success(zfbMonitorTrafficSetMealService.getById(id));
    }


    @ApiOperation(value = "删除-监控设备流量套餐")
    @LogControllerAnnotation(intoDB = true, methodType = MethodType.DELETE, description = "删除-监控设备流量套餐")
    @RequestMapping(value = "/deleteTrafficSetMeal", method = RequestMethod.GET)
    public CommonResult deleteTrafficSetMeal(@RequestParam(value = "id") Integer id) {
        return CommonResult.success(zfbMonitorTrafficSetMealService.deleteById(id));
    }
}
